Auto-update ms.date in docs-mslearn on PR changes#1985
Conversation
Add GitHub Action workflow that automatically updates the ms.date field in docs-mslearn markdown files when they are modified in a pull request. This ensures documentation dates stay current without manual intervention. Also adds: - Pester unit test to validate the GitHub Action workflow - Pester lint test to validate ms.date format in all docs-mslearn files - New -Actions parameter to Test-PowerShell.ps1 for running Action tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces automation to keep Microsoft Learn documentation dates current by automatically updating the ms.date field in docs-mslearn markdown files when they are modified in a pull request. This reduces manual maintenance burden and ensures documentation metadata stays accurate.
Changes:
- Adds a GitHub Action workflow that triggers on docs-mslearn markdown file changes, updates ms.date to the current date, and commits the change back to the PR branch
- Implements comprehensive unit tests for the GitHub Action workflow structure and security
- Adds lint tests to validate ms.date format compliance across all docs-mslearn files
- Extends the test runner to support GitHub Action tests with a new
-Actionsparameter
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/update-mslearn-dates.yml | New workflow that auto-updates ms.date fields in changed docs-mslearn markdown files |
| src/powershell/Tests/Unit/Action.UpdateMsLearnDates.Tests.ps1 | Unit tests validating workflow structure, triggers, permissions, and security |
| src/powershell/Tests/Lint/MsLearnDocs.Tests.ps1 | Lint tests ensuring ms.date format compliance (MM/DD/YYYY) across all docs-mslearn files |
| src/scripts/Test-PowerShell.ps1 | Added -Actions parameter to run GitHub Action tests (Action.*.Tests.ps1 pattern) |
| run: | | ||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --local user.name "github-actions[bot]" | ||
| git add docs-mslearn/**/*.md |
There was a problem hiding this comment.
The git add command uses a wildcard pattern that could stage unintended files. If there are other uncommitted changes in docs-mslearn markdown files (from previous steps or manual changes), they will be included in the commit.
Consider using git add with the specific files that were modified by this workflow. Since the sed commands only modify the files in the changed-files list, you could iterate over those files or use 'git add -u docs-mslearn/' to only add tracked files that were modified, which is safer than the wildcard pattern.
| git add docs-mslearn/**/*.md | |
| git add -u docs-mslearn/ |
🛠️ Description
Add a GitHub Action workflow that automatically updates the
ms.datefield in docs-mslearn markdown files when they are modified in a pull request. This ensures documentation dates stay current without manual intervention.Changes include:
.github/workflows/update-mslearn-dates.yml): Triggers on PRs that modifydocs-mslearn/**/*.mdfiles, updates thems.datefrontmatter to the current date, and commits the change back to the PR branchAction.UpdateMsLearnDates.Tests.ps1): Validates the GitHub Action workflow structure, triggers, permissions, and security considerationsMsLearnDocs.Tests.ps1): Validates all docs-mslearn files have properms.datefrontmatter in MM/DD/YYYY format-Actionsparameter toTest-PowerShell.ps1for running GitHub Action tests (pattern:Action.*.Tests.ps1)📋 Checklist
🔬 How did you test this change?
🙋♀️ Do any of the following that apply?
📑 Did you update
docs/changelog.md?📖 Did you update documentation?